package com.bootdo.api.util;

import java.lang.reflect.Field;

import com.bootdo.api.response.BaseResponse;


/**
 * 接口验证异常
 * 
 * @author hrh
 * @date 2016年5月30日 下午2:34:30
 */
@SuppressWarnings("serial")
public class ValidateException extends Exception {
	private Status status;

	private ExceptionType exceptionType;

	private String errMsg;

	private Field field;
	
	private BaseResponse response;
	
	public ValidateException(Status status, ExceptionType exceptionType) {
		this.status = status;
		this.exceptionType = exceptionType;
	}

	public ValidateException(Status status, ExceptionType exceptionType, String errMsg) {
		this.status = status;
		this.exceptionType = exceptionType;
		this.errMsg = errMsg;
	}

	public ValidateException(Status status, ExceptionType exceptionType, String errMsg, Field field) {
		// 重新设置回私有权限
		if (field != null) {
			field.setAccessible(false);
		}
		this.status = status;
		this.exceptionType = exceptionType;
		this.errMsg = errMsg;
		this.field = field;
	}

	public ValidateException(Status status, ExceptionType exceptionType, String errMsg, BaseResponse response) {
		this.status = status;
		this.exceptionType = exceptionType;
		this.errMsg = errMsg;
		this.response = response;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public ExceptionType getexceptionType() {
		return exceptionType;
	}

	public void setexceptionType(ExceptionType exceptionType) {
		this.exceptionType = exceptionType;
	}

	public String getErrMsg() {
		return errMsg;
	}

	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}

	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}
}
